import axios from "@/utils/http";
enum Api {
    getInfo = "/file/oss/getInfo",
    GetFileList = "/file/oss/GetFileList",
    UploadInformation = "/file/oss/UploadInformation",
    UploadFileInfo = "/file/oss/UploadFileInfo",
    GetGroupName = "/file/oss/GetGroupName",
}
interface AssumedRoleUser {
    Arn: string;
    AssumedRoleId: string;
}
interface Credentials {
    AccessKeySecret: string;
    Expiration: string;
    AccessKeyId: string;
    securityToken: string;
}
interface UploadResponse {
    uuid: string;
}

export interface OssResponse {
    RequestId: string;
    assumedRoleUser: AssumedRoleUser;
    credentials: Credentials;
    point: string;
    address: string;
    bucket: string;
}

export interface SysFileResp {
    updateTime: string;
    createTime: string;
    path: string;
    name: string;
    uUid: string;
    size: number;
    suffix: string;
    userId: string;
    groupName: string;
}
interface ChangeSysFileResp {
    uUid: string;
    groupName: string;
}

export interface ListData {
    total: number;
    list: SysFileResp[];
}
export interface ListParmas {
    page: number;
    pageSize: number;
    keyword: string;
    groupName: string;
    suffix?: string;
}


export interface UploadInfoResponse {
    path: string
    name: string
    uUid: string
    size: number
    suffix: string
    userId: string
    groupName: string
}
interface GroupNameResp {
    names: string[]
}
interface UploadInfoResp {}
// 获取oss信息
export const ossGetInfo = <OssResponse>() => {
    return axios.get<OssResponse>(Api.getInfo);
};

// 获取文件列表
export const GetFileList = <ListData>(parmas: ListParmas) => {
    return axios.get<ListData>(Api.GetFileList, parmas);
};

// 改变文件分组
export const setgroupName = (parmas: ChangeSysFileResp) => {
    return axios.post<SysFileResp>(Api.UploadInformation, parmas);
};

// 获取文件分组
export const getGroupName = () => {
    return axios.get<GroupNameResp>(Api.GetGroupName);
};

// 上传文件信息
export const UploadFileInfo = (parmas: UploadInfoResponse) => {
    return axios.post<UploadInfoResp>(Api.UploadFileInfo, parmas);
};
